<?php
class PNUserHotelRateArray extends PNObjectArray {
  function PNUserHotelRateArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'hotelbooking_hotelrate';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';
    
    $this->_objJoin[] = array ( 'join_table' => 'hotelbooking_hotelroom',
                                'compare_field_table' => 'hotelRoom_id',
                                'compare_field_join' => 'id',
                                'join_field' => array('id', 'name','description','adult','child','extrabed','sort'),
                                'object_field_name' => array('room_id', 'room_name', 'room_description','room_adult','room_child','room_extrabed','room_sort')
                        );

    $this->_objJoin[] = array ( 'join_table' => 'hotelbooking_hotelseason',
                                'compare_field_table' => 'season_id',
                                'compare_field_join' => 'id',
                                'join_field' => array('id', 'name', 'description', 'date_start', 'date_end'),
                                'object_field_name' => array('season_id', 'season_name', 'season_description', 'season_date_start', 'season_date_end')
                        );
    
    $this->_init($init, $where);
  }

  function genFilter(){
    $uid = SessionUtil::getVar('uid');
    
    if($uid){
      $wheres[] = $this->_columns['cr_uid']."  = ".$uid;
    }
    if(count($wheres)>1){
      $where = implode(" AND ",$wheres);
    }else{
      $where = $wheres[0];
    }
    
    return $where;
  }
}